package com.zm.spring.dependency.injection.setter.demo;

import com.zm.spring.dependency.injection.entity.UserHolder;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * Autowire 注入
 */
public class AutowiringDependencySetterInjectionDemo {


    public static void main(String[] args) {

        AnnotationConfigApplicationContext annotationConfigApplicationContext
                = new AnnotationConfigApplicationContext();
        BeanDefinitionReader reader = new XmlBeanDefinitionReader(annotationConfigApplicationContext);
        reader.loadBeanDefinitions("classpath:/META-INF/spring-ioc.xml","classpath:/META-INF/autowiring-dependency-injection.xml");
        annotationConfigApplicationContext.refresh();
        UserHolder userHolder = annotationConfigApplicationContext.getBean(UserHolder.class);
        System.out.println(userHolder);
        annotationConfigApplicationContext.close();
    }

}
